package com.lazypeople.domain;

public enum DownloadStatus {
    // 就绪
    READY(0, "就绪"),
    // 下载中
    DOWNLOADING(200, "下载中"),
    // 暂停
    PAUSED(300, "暂停"),
    // 下载完成
    COMPLETED(400, "下载完成"),
    // 下载失败
    FAILED(500, "下载失败"),
    // 下载取消
    CANCELLED(600, "下载取消"),
    // 不支持
    NOT_SUPPORTED(700, "不支持");

    private final int status;
    private final String statusName;

    DownloadStatus(int status, String statusName) {
        this.status = status;
        this.statusName = statusName;
    }

    public int getStatus() {
        return status;
    }

    public String getStatusName() {
        return statusName;
    }

    public static DownloadStatus getDownloadStatus(int status) {
        for (DownloadStatus downloadStatus : DownloadStatus.values()) {
            if (downloadStatus.getStatus() == status) {
                return downloadStatus;
            }
        }
        return NOT_SUPPORTED;
    }

    public static String getStatusName(int status) {
        DownloadStatus downloadStatus = getDownloadStatus(status);
        if (downloadStatus != null) {
            return downloadStatus.getStatusName();
        }
        return NOT_SUPPORTED.getStatusName();
    }
}